package org.thanos.iot.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.thanos.iot.service.file.SysFileService;

import java.util.List;
import java.util.UUID;

@Slf4j
@Component
public class ScheduleTask {

    @Autowired
    private SysFileService sysFileService;

    //每天的1点触发任务
    @Scheduled(cron = "0 0 1 * * ?", zone = "Asia/Shanghai")
    public void deleteDisuseFile() {
        log.error("GraphicFileClearTask invoke in : {}", System.currentTimeMillis());
        List<Integer> usingFileIds = graphicComponentFileService.getComponentFileIds();
        sysFileService.deleteObsoleteFiles(usingFileIds);
    }
}
